All Questions
Tagged with parsingjavascript
95 questions
1vote
2answers
171views
Strings to array
I've written a simple text tokenizer in JavaScript which works in my specific case, but I do not think it is maintainable (for example, if the requirement ever changed to allow newlines when ...
2votes
2answers
170views
Parse a string with titles and subitems to an object
I want to parse a string to an array of object with following those rules: parse line by line if line starts with "*" this is a title if line starts with "\s**" this is a ...
6votes
5answers
2kviews
Extracting a part of a URL path
I have a string like the one below from which I am extracting the tariff name. ...
3votes
4answers
1kviews
Convert number 1-5 from its spelt-out form
I'm working with an API that for some strange reason returns star ratings as words, like FIVE,FOUR,THREE,TWO,ONE. As far as I can see, there's no way to just get ...
5votes
1answer
219views
How could this indentation-based lexer be simplified?
I finally got this lexer working, full implementation here. How can the lex function be simplified? The goal is to take a tree of indentation-based text, and ...
4votes
1answer
188views
Convert ASCII representations of phonetics to Unicode characters
Here is some working code for converting an input string to an output string: ...
1vote
1answer
617views
Parse proxy strings to array of objects
The goal of this module is to take in a string (user input, someone copy and pasting a large list of proxies) and parse it into an array of objects. I appreciate any and all feedback, but I'm ...
4votes
3answers
3kviews
Parsing "key: value" format in which values can span multiple lines
So I've written a function which parses a fairly simple key-value pair syntax. Each pair can span across multiple lines, as long as the value does not have a colon in it. If it does, then any new line ...
12votes
2answers
331views
A simple parser generator
I need to parse simple DSLs in a few projects. Since I don't know BNF or other grammars, I figured an alternative would be to use a simple parser generator. I'm looking for improvements to the lexer/...
7votes
3answers
260views
parse date and number from API results
I'm slurping up fields from an API that returns an array of fields. Each field in the array is a String that actually contains two separate fields (a number and a date). The number is enclosed in ...
7votes
2answers
16kviews
Convert Exponential (e-Notation) Numbers to Decimals
I have the following short function code that converts Exponential (e-Notation) Numbers to Decimals, allowing the output of large number of decimal places. I needed to cover all the e-notation ...
2votes
2answers
73views
String data manipulated given CSV variables
The Requirements: List the expensable items sorted by date and location given two variables: 'categories' and 'expenses'. The Categories variable provides the following information in order: Category ...
4votes
1answer
167views
JSON to CSS in JavaScript
I'm working on a JSON to CSS converter in NodeJS, which takes a .json file and generates a .css file with its utility classes from it. .json example ...
4votes
1answer
74views
Rendering the AuthorName using the DOMParser to read XML
I need to concatenate the LastName and Initials and all of that authors affiliations. Is there a better way or faster way to do ...
2votes
0answers
54views
Ensuring a valid JavaScript string in security-critical application
I'm writing an application where users can write custom expressions which are then converted to JavaScript functions and executed. The expressions are used for filtering and sorting data from a ...